//package com.inspur.edp.bef.dtgenerator.core.rtgen.managergen.beforequerydtmgen;
//
//
//import com.inspur.edp.bef.api.attr.BeforeQueryDtmsAttribute;
//import com.inspur.edp.bef.api.attr.BeforeQueryDtmsExtendAttribute;
//import com.inspur.edp.caf.generator.baseInfo.TypeInfo;
//import com.inspur.edp.caf.generator.field.FieldGenerator;
//import com.inspur.edp.cef.api.determination.attr.DeterminationsAttribute;
//import com.inspur.edp.cef.api.determination.attr.DeterminationsExtendAttribute;
//import com.inspur.edp.cef.rtgenerator.common.CefMgrTypeInfo;
//import com.inspur.edp.cef.rtgenerator.managergen.ManagerGeneratorContext;
//import com.inspur.edp.cef.spi.determination.IDetermination;
//import org.eclipse.jdt.core.dom.*;
//
//import java.util.ArrayList;
//import java.util.List;
//
//public class GetDeterminationsFieldGenerator extends FieldGenerator
//{
//	private ManagerGeneratorContext entityContext;
//
//	public GetDeterminationsFieldGenerator(ManagerGeneratorContext entityContext)
//	{
//		this.entityContext = entityContext;
//	}
//
//	@Override
//	protected java.util.ArrayList<Modifier.ModifierKeyword> getAccessModifier()
//	{return new java.util.ArrayList<Modifier.ModifierKeyword>(java.util.Arrays.asList(new Modifier.ModifierKeyword[] { Modifier.ModifierKeyword.PRIVATE_KEYWORD, Modifier.ModifierKeyword.STATIC_KEYWORD}));}
//
//	public static String ItemName="determinationsList";
//	@Override
//	protected String getFieldName(){return ItemName;}
//
//	@Override
//	protected TypeInfo getFieldType() {
//		TypeInfo typeInfo = new TypeInfo(List.class.getTypeName());
//		typeInfo.setIsParameterizedType(true);
//		typeInfo.getArguments().add(new TypeInfo(IDetermination.class));
//		return typeInfo;
//	}
//
//	@Override
//	protected Expression buildGetMethodBody() {
//		ClassInstanceCreation arrayListCreation =ast.newClassInstanceCreation();
//		setFieldType(arrayListCreation);
//		setFieldArguments(arrayListCreation);
//		return arrayListCreation;
//	}
//
//	private void setFieldArguments(ClassInstanceCreation arrayListCreation) {
//		MethodInvocation methodInvocation=ast.newMethodInvocation();
//		setArrayAslistMInvocationExpression(methodInvocation);
//		setArrayAslistMInvocationName(methodInvocation);
//		setArrayAslistMInvocationArguments(methodInvocation);
//		arrayListCreation.arguments().add(methodInvocation);
//	}
//
//	private void setArrayAslistMInvocationArguments(MethodInvocation methodInvocation) {
//		ArrayCreation arrayCreation=ast.newArrayCreation();
//		ArrayType arrayType = ast.newArrayType(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(IDetermination.class).getType(ast));
//		arrayCreation.setType(arrayType);
//		arrayCreation.setInitializer(createArrayInitializer());
//		methodInvocation.arguments().add(arrayCreation);
//	}
//
//	private ArrayInitializer createArrayInitializer() {
//		ArrayInitializer initializer=ast.newArrayInitializer();
//		ArrayList<Class> types =prepareInstance();
//		if(types==null||types.size()==0)
//			return initializer;
//		for (Class type :types)
//		{
//			ClassInstanceCreation classInstanceCreation=ast.newClassInstanceCreation();
//			classInstanceCreation.setType(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(type).getType(ast));
//			addImport(type.getTypeName());
//			initializer.expressions().add(classInstanceCreation);
//		}
//		return initializer;
//	}
//
//	private void setArrayAslistMInvocationName(MethodInvocation methodInvocation) {
//		methodInvocation.setName(ast.newSimpleName("asList"));
//	}
//
//	private void setArrayAslistMInvocationExpression(MethodInvocation methodInvocation) {
//		QualifiedName name=	ast.newQualifiedName(getQualifier(),ast.newSimpleName("Arrays"));
//		methodInvocation.setExpression(name);
//	}
//
//	private Name getQualifier() {
//		return ast.newQualifiedName(ast.newSimpleName("java"),ast.newSimpleName("util"));
//	}
//
//	private void setFieldType(ClassInstanceCreation arrayListCreation) {
//		ParameterizedType arrayListType =ast.newParameterizedType(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(ArrayList.class).getType(ast));
//		arrayListCreation.setType(arrayListType);
//	}
//
//
//	private java.util.ArrayList<BeforeQueryDtmsAttribute> getBasicCustomAttributes(java.lang.Class type)
//	{
//		java.util.ArrayList<BeforeQueryDtmsAttribute> list = new java.util.ArrayList<BeforeQueryDtmsAttribute>();
//		Object[] attributes = type.getDeclaredAnnotationsByType(BeforeQueryDtmsAttribute.class);
//		for (Object obj : attributes)
//		{
//			if (obj instanceof BeforeQueryDtmsAttribute)
//			{
//				BeforeQueryDtmsAttribute da = (BeforeQueryDtmsAttribute)((obj instanceof BeforeQueryDtmsAttribute) ? obj : null);
//				if (da != null)
//				{
//					list.add(da);
//				}
//			}
//		}
//		return list;
//	}
//
//	private java.util.ArrayList<BeforeQueryDtmsExtendAttribute> getExtendCustomAttribute(java.lang.Class[] type)
//	{
//		java.util.ArrayList<BeforeQueryDtmsExtendAttribute> list = new java.util.ArrayList<BeforeQueryDtmsExtendAttribute>();
//		for (java.lang.Class t : type)
//		{
//			Object[] attributes = t.getDeclaredAnnotationsByType(BeforeQueryDtmsExtendAttribute.class);
//			for (Object obj : attributes)
//			{
//				if (obj instanceof BeforeQueryDtmsExtendAttribute)
//				{
//					BeforeQueryDtmsExtendAttribute da = (BeforeQueryDtmsExtendAttribute)((obj instanceof BeforeQueryDtmsExtendAttribute) ? obj : null);
//					if (da != null)
//					{
//						list.add(da);
//					}
//				}
//			}
//		}
//
//		return list;
//	}
//
//	private java.util.ArrayList<BeforeQueryDtmsAttribute> getSameLayerAttributes(CefMgrTypeInfo parentTypeInfo)
//	{
//		if (parentTypeInfo == null)
//		{
//			return new java.util.ArrayList<BeforeQueryDtmsAttribute>();
//		}
//		java.lang.Class type = parentTypeInfo.getImplType();
//		java.util.ArrayList<BeforeQueryDtmsAttribute> list = new java.util.ArrayList<BeforeQueryDtmsAttribute>();
//		Object[] attributes = type.getDeclaredAnnotationsByType(BeforeQueryDtmsAttribute.class);
//		for (Object obj : attributes)
//		{
//			if (obj instanceof BeforeQueryDtmsAttribute)
//			{
//				BeforeQueryDtmsAttribute da = (BeforeQueryDtmsAttribute)((obj instanceof BeforeQueryDtmsAttribute) ? obj : null);
//				if (da != null)
//				{
//					list.add(da);
//				}
//			}
//		}
//		return list;
//	}
//
//	private ArrayList<Class> prepareInstance()
//	{
//		java.util.ArrayList<CefMgrTypeInfo> infoList = entityContext.getProjContext().getMgrTypes();
//		java.util.ArrayList<BeforeQueryDtmsAttribute> daList = getBasicCustomAttributes(entityContext.getProjContext().getCurrentTypeInfo().getImplType());
//		//.getEntityEntityTypeInfos().get("RootNode").getActionImplType());
//		int capacity = infoList.size() - 1;
//		java.lang.Class[] dearray = new java.lang.Class[capacity];
//		for (int i = 0; i < capacity; i++)
//		{
//			//TODO: extend也应该从be实现类上找
//			dearray[i] = infoList.get(i + 1).getImplType();
//		}
//		java.util.ArrayList<BeforeQueryDtmsExtendAttribute> deaList = getExtendCustomAttribute(dearray);
//		java.util.ArrayList<BeforeQueryDtmsAttribute> daLayerList = getSameLayerAttributes(entityContext.getProjContext().getParentTypeInfo());
//		java.util.ArrayList<java.lang.Class> result = new java.util.ArrayList<java.lang.Class>();
//
//		for (BeforeQueryDtmsExtendAttribute dea : deaList)
//		{
//			if (dea.beforeDeterminations() != null)
//			{
//				for (java.lang.Class type : dea.beforeDeterminations())
//				{
//					result.add(type);
//				}
//			}
//		}
//		for (BeforeQueryDtmsAttribute da : daList)
//		{
//			if (da.value() != null)
//			{
//				for (java.lang.Class type : da.value())
//				{
//					result.add(type);
//				}
//			}
//		}
//		for (BeforeQueryDtmsExtendAttribute dea : deaList)
//		{
//			if (dea.afterDeterminations() != null)
//			{
//				for (java.lang.Class type : dea.afterDeterminations())
//				{
//					result.add(type);
//				}
//			}
//		}
////		for (DeterminationsAttribute da : daLayerList)
////		{
////			if (da.determinations() != null)
////			{
////				for (java.lang.Class type : da.determinations())
////				{
////					result.add(type);
////				}
////			}
////		}
//		return result;
//	}
////	@Override
////	protected EqualsValueClauseSyntax buildGetMethodBody()
////	{
////		if (PrepareInstance().length == 0)
////		{
////			return SyntaxFactory.EqualsValueClause(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression));
////		}
////		return SyntaxFactory.EqualsValueClause(SyntaxFactory.ObjectCreationExpression(TypeUtils.GetTypeSyntax(java.util.ArrayList<IDetermination>.class)).WithInitializer(SyntaxFactory.InitializerExpression(SyntaxKind.CollectionInitializerExpression, SyntaxFactory.<ExpressionSyntax>SeparatedList(PrepareInstance()))));
////	}
////
////	private java.util.ArrayList<BeforeQueryDtmsExtendAttribute> getExtendCustomAttribute(java.lang.Class[] type)
////	{
////		java.util.ArrayList<BeforeQueryDtmsExtendAttribute> list = new java.util.ArrayList<BeforeQueryDtmsExtendAttribute>();
////		for (java.lang.Class t : type)
////		{
////			var attr = t.<BeforeQueryDtmsExtendAttribute>GetCustomAttribute(true);
////			if (attr != null)
////			{
////				list.add(attr);
////			}
////		}
////		return list;
////	}
////
////	//private BeforeQueryDtmsAttribute getSameLayerAttributes(CefMgrTypeInfo parentTypeInfo)
////	//{
////	//    if (parentTypeInfo == null || parentTypeInfo.ImplType == null)
////	//        return null;
////	//    var type = parentTypeInfo.ImplType;
////	//    return type.GetCustomAttribute<BeforeQueryDtmsAttribute>(true);
////	//}
////
////	private SyntaxNodeOrToken[] prepareInstance()
////	{
////		java.util.ArrayList<CefMgrTypeInfo> infoList = entityContext.ProjContext.MgrTypes;
////		var daList = entityContext.ProjContext.CurrentTypeInfo.ImplType.<BeforeQueryDtmsAttribute>GetCustomAttribute(true);
////		int capacity = infoList.size() - 1;
////		java.lang.Class[] dearray = new java.lang.Class[capacity];
////		for (int i = 0; i < capacity; i++)
////		{
////			dearray[i] = infoList.get(i + 1).ImplType;
////		}
////		java.util.ArrayList<BeforeQueryDtmsExtendAttribute> deaList = GetExtendCustomAttribute(dearray);
////		//List<DeterminationsAttribute> daLayerList = GetSameLayerAttributes(entityContext.ProjContext.ParentTypeInfo);
////		java.util.ArrayList<java.lang.Class> result = new java.util.ArrayList<java.lang.Class>();
////
////		for (var dea : deaList)
////		{
////			if (dea.BeforeDeterminations != null)
////			{
////				for (java.lang.Class type : dea.BeforeDeterminations)
////				{
////					result.add(type);
////				}
////			}
////		}
////		if(daList != null && daList.Determinations != null)
////		{
////			for (java.lang.Class type : daList.Determinations)
////			{
////				result.add(type);
////			}
////		}
////		for (var dea : deaList)
////		{
////			if (dea.AfterDeterminations != null)
////			{
////				for (java.lang.Class type : dea.AfterDeterminations)
////				{
////					result.add(type);
////				}
////			}
////		}
////		//foreach (DeterminationsAttribute da in daLayerList)
////		//{
////		//    if (da.Determinations != null)
////		//        foreach (Type type in da.Determinations)
////		//        {
////		//            result.Add(type);
////		//        }
////		//}
////
////		java.util.ArrayList<SyntaxNodeOrToken> list = new java.util.ArrayList<SyntaxNodeOrToken>();
////		for (int i = 0; i < result.size(); i++)
////		{
////			list.add(SyntaxFactory.ObjectCreationExpression(TypeUtils.GetTypeSyntax(result.get(i))));
////			list.add(SyntaxFactory.Token(SyntaxKind.CommaToken));
////		}
////		int index = list.size() - 1;
////		if (index < 0)
////		{
////			return list.toArray(new SyntaxNodeOrToken[]{});
////		}
////		list.remove(index);
////
////		return list.toArray(new SyntaxNodeOrToken[]{});
////	}
//}